import { CHANGE_BANNERS, CHANGE_RECOMMENDS } from './constants'
import axios from 'axios'

export const changeBanners = (banners) => ({
  type: CHANGE_BANNERS,
  banners,
})

export const changeRecommends = (recommends) => ({
  type: CHANGE_RECOMMENDS,
  recommends,
})

export const fetchHomeMultidataAction = () => {
  return function (dispatch, getState) {
    axios.get('http://123.207.32.32:8000/home/multidata').then((res) => {
      const banners = res.data.data.banner.list
      const recommends = res.data.data.recommend.list
      dispatch(changeBanners(banners))
      dispatch(changeRecommends(recommends))
    })
  }
}
